package kp.srs.client.gin;

import com.google.gwt.event.shared.SimpleEventBus;
import com.google.gwt.inject.client.AbstractGinModule;
import com.google.gwt.place.shared.PlaceController;
import com.google.inject.Provides;
import com.google.web.bindery.event.shared.EventBus;

import javax.inject.Singleton;

/**
 * The Module for the Ginjector. Declares the bindings between classes.
 */
public class SrsGinModule extends AbstractGinModule {

  @Override
  protected void configure() {
    
    // Binding for the EventBus
    // the example recommends to import javax.inject instead of com.gogle.inject
    // but I use googles instead, it's just something with the path when moving modules
    bind(EventBus.class).to(SimpleEventBus.class).in(Singleton.class);
    
    // Binding for the Activity Mapper
    //bind(ActivityMapper.class).to(SrsActivityMapper.class);
    
    // The Binding for the Quest1View is done by annotating the constructor
    // with the @Inject annotation  
  }
  
  
  /**
   * The PlaceController has no default constructor, so a method annotated with @Provides that
   * returns a PlaceController is required and defined below.
   * <p>
   * Had PlaceController a default constructor (or could I add the @Inject annotation to it, 
   * I would just define the binding by bind(PlaceController.class); (I guess this 
   * definition is required)
   */
  @Provides
  PlaceController providePlaceController() {
    EventBus eventBus = SrsGinjector.INSTANCE.getEventBus();
    return new PlaceController(eventBus);
  }
  
}
